Export Paper Model #38441

Closed
opened 2014-02-02 00:10:30 +01:00 by Adam Dominec · 34 comments
Member

This add-on exports the active Mesh object as an SVG document ready to be printed and crafted into a real-world model.

For basic testing or simple models, it is enough to run the Export Paper Model operator and pick a file name. Multiple files will be created if more pages are necessary, since some vector editors (such as Inkscape) cannot handle multipage SVGs.
Models containing N-gon faces (N > 3) may produce a distorted net and models containing doubled vertices, edges or other such ugly phenomena may cause the script crash.

The layout of the net can be customized using Seams, representing the edges to be cut. A preview of the result can be obtained by running the Make Unfoldable operator and viewing the separated islands in the 3D View (controlled in the Toolbox) or in the UV editor, if that option is enabled during unfolding. The operator will soon be renamed to Unfold.

Further details and part of the algorithms used are described in the manual page on Blender wiki.

Current version (at the time of posting) of the script for Blender 2.69: io_export_paper_model.py
Current version of the script
A prerelease version for Blender 2.70, including tabbed interface.

The script uses tabs for indentation because I just like them. However, if that is a problem, I can of course convert to spaces.
I posted this addon as a patch two years ago, but that one is closed now as the script was not working properly back then.

This add-on exports the active Mesh object as an SVG document ready to be printed and crafted into a real-world model. For basic testing or simple models, it is enough to run the *Export Paper Model* operator and pick a file name. Multiple files will be created if more pages are necessary, since some vector editors (such as Inkscape) cannot handle multipage SVGs. Models containing N-gon faces (N > 3) may produce a distorted net and models containing doubled vertices, edges or other such ugly phenomena may cause the script crash. The layout of the net can be customized using Seams, representing the edges to be cut. A preview of the result can be obtained by running the *Make Unfoldable* operator and viewing the separated islands in the 3D View (controlled in the Toolbox) or in the UV editor, if that option is enabled during unfolding. The operator will soon be renamed to *Unfold*. Further details and part of the algorithms used are described in the [manual page ](http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Paper_Model) on Blender wiki. Current version (at the time of posting) of the script for Blender 2.69: [io_export_paper_model.py](https://archive.blender.org/developer/F75776/io_export_paper_model.py) [Current version of the script ](https://raw2.github.com/addam/Export-Paper-Model-from-Blender/master/io_export_paper_model.py) [A prerelease version ](https://raw2.github.com/addam/Export-Paper-Model-from-Blender/prerelease/io_export_paper_model.py) for Blender 2.70, including tabbed interface. The script uses tabs for indentation because I just like them. However, if that is a problem, I can of course convert to spaces. I posted this addon as a patch two years ago, but that one is closed now as the script was not working properly back then.
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @emu-3

Added subscriber: @emu-3
Author
Member

I forgot to mention the corresponding BA.org thread . I use it for announcements and people mostly use it for reporting bugs.

I forgot to mention the corresponding [BA.org thread ](http://blenderartists.org/forum/showthread.php?186071). I use it for announcements and people mostly use it for reporting bugs.

Added subscriber: @ideasman42

Added subscriber: @ideasman42

Added diff, to be able to comment on code.

Added diff, to be able to comment on code.
Author
Member

I currently commit updates to the prerelease branch on github. I mostly cleaned up the code, and I should yet fix the Limit Island Size functionality.
Then, I will post the file as an attachment again.

I'm not in much of a hurry anymore since I was told the script can't get to the 2.70 release anyway.

Thanks for the 2d cross product :)

I currently commit updates to the prerelease branch on github. I mostly cleaned up the code, and I should yet fix the *Limit Island Size* functionality. Then, I will post the file as an attachment again. I'm not in much of a hurry anymore since I was told the script can't get to the 2.70 release anyway. Thanks for the 2d cross product :)

I also wont have much time to review or give feedback, its a good target to have this ready, after 2.70. typically its good to submit features well before release date.

I also wont have much time to review or give feedback, its a good target to have this ready, after 2.70. typically its good to submit features well before release date.
Author
Member

I cleaned up the code and did a few other fixes. There are still many improvements to make, but I believe the code is ready for review.
The current version is here: io_export_paper_model.py. Eventual updates will be on github (the attachment corresponds to e48f68ef)

I cleaned up the code and did a few other fixes. There are still many improvements to make, but I believe the code is ready for review. The current version is here: [io_export_paper_model.py](https://archive.blender.org/developer/F88490/io_export_paper_model.py). Eventual updates will be on [github ](https://raw2.github.com/addam/Export-Paper-Model-from-Blender/master/io_export_paper_model.py) (the attachment corresponds to `e48f68ef`)

@emu-3, had a quick look

Suggestions:

  • use os.sep rather than / as path separator.
  • use __slots__ for all classes, avoids accidental attribute creation on typos and is more memory efficient.

Looks like we should support mathutils.geometry.normal() for any number of vectors (not just 3-4), but that will have to wait until after release.

@emu-3, had a quick look Suggestions: - use `os.sep` rather than `/` as path separator. - use `__slots__` for all classes, avoids accidental attribute creation on typos and is more memory efficient. Looks like we should support mathutils.geometry.normal() for any number of vectors (not just 3-4), but that will have to wait until after release.
Author
Member

I was not aware of __slots__, thanks. I added it to all the classes for mesh data, not to the singletons and operators. It even made a performance boost of about 10% on my system :)

Regarding os.sep it's a bit trickier because (I believe) the SVG file needs paths separated by forward slashes. Now I wrote that explicitly as a string replacement. I suppose the script was actually broken on Windows, but nobody told me :-/

The updated file is in git and also here: io_export_paper_model.py.

I was not aware of `__slots__`, thanks. I added it to all the classes for mesh data, not to the singletons and operators. It even made a performance boost of about 10% on my system :) Regarding `os.sep` it's a bit trickier because (I believe) the SVG file needs paths separated by forward slashes. Now I wrote that explicitly as a string replacement. I suppose the script was actually broken on Windows, but nobody told me :-/ The updated file is in git and also here: [io_export_paper_model.py](https://archive.blender.org/developer/F88697/io_export_paper_model.py).
Author
Member

Hello,
could somebody please check this script (the updated differential revision)? I made a lot of fixes and improvements, and I'd love to get it into a release.
EDIT: the github link seems to be broken. Try this one instead.

Hello, could somebody please check this script (the updated differential revision)? I made a lot of fixes and improvements, and I'd love to get it into a release. EDIT: the github link seems to be broken. Try [this one ](https://raw.githubusercontent.com/addam/Export-Paper-Model-from-Blender/master/io_export_paper_model.py) instead.
Member

Added subscriber: @BrendonMurphy

Added subscriber: @BrendonMurphy
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Brendon Murphy self-assigned this 2015-09-01 15:11:00 +02:00
Member

hi, closing this task, addon is now in contrib
for future patches/updates please create a new task.
for bug reports: https://developer.blender.org/maniphest/project/3/type/Bug/

hi, closing this task, addon is now in contrib for future patches/updates please create a new task. for bug reports: https://developer.blender.org/maniphest/project/3/type/Bug/

Added subscriber: @SeaMonsterNY

Added subscriber: @SeaMonsterNY

I love this add-on! I use it extensively, however I often get a Traceback error that I just can't get around. I'm teaching kids modelling and we plan on making paper craft sculptures, the add-on however is not reliable enough for using in a school setting. I hope you can help me figure out what is wrong. Thank you!!

Report Error
Traceback (most recent call last):
File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 1837, in invoke self.unfolder.prepare(cage_size, create_uvmap=self.do_create_uvmap, scale=sce.unit_settings.scale_length/self.scale)
File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 160 in prepare self.mesh.generate_cuts(cage_size/scale if cage_size else None, priority_effect)
File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 284, in generate_cuts if island_a.join(island_b, edge, size_limit=page_size):
File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 1003, in join segments.sort(key=slope_from(position))
File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 904, in slope return (vec.y/vec.length + 1) if ((vec.x,vec.y) > (0,0)) else (-1 -vec.y / vet.length)
ZeroDivisionError: float division by zero

location :-1

I love this add-on! I use it extensively, however I often get a Traceback error that I just can't get around. I'm teaching kids modelling and we plan on making paper craft sculptures, the add-on however is not reliable enough for using in a school setting. I hope you can help me figure out what is wrong. Thank you!! Report Error Traceback (most recent call last): File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 1837, in invoke self.unfolder.prepare(cage_size, create_uvmap=self.do_create_uvmap, scale=sce.unit_settings.scale_length/self.scale) File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 160 in prepare self.mesh.generate_cuts(cage_size/scale if cage_size else None, priority_effect) File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 284, in generate_cuts if island_a.join(island_b, edge, size_limit=page_size): File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 1003, in join segments.sort(key=slope_from(position)) File"// Applications/Blender/blender.app/Contents/Resources/2.7/scripts/addons_contrib/io_export_paper_model.py", line 904, in slope return (vec.y/vec.length + 1) if ((vec.x,vec.y) > (0,0)) else (-1 -vec.y / vet.length) ZeroDivisionError: float division by zero location <unknown location>:-1
Member

Added subscriber: @Blendify

Added subscriber: @Blendify
Member
@SeaMonsterNY please create a bug report here: https://developer.blender.org/maniphest/task/create/?project=3&type=Bug

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Updated the addon to upstream revision 13d8334. That should solve this bug (and others).

Updated the addon to [upstream](https://github.com/addam/Export-Paper-Model-from-Blender) revision 13d8334. That should solve this bug (and others).
Author
Member

@dr.sybren Thank you! I remember I had some issues with pushing to the addons-contrib repo, but I'll try again and add some more updates soon.

@dr.sybren Thank you! I remember I had some issues with pushing to the `addons-contrib` repo, but I'll try again and add some more updates soon.

Added subscriber: @nikitron

Added subscriber: @nikitron

This comment was removed by @nikitron

*This comment was removed by @nikitron*

Added subscriber: @MaxenceLeretdAubigny

Added subscriber: @MaxenceLeretdAubigny

Hey guys,

I'm using quite a lot that add-on for few months. There are 2 bugs that are pretty annoying and time consuming:

  • Abreviation. I can't figure out if I do something wrong or if the script has a problem on that side. It only take the first number in count when automatically generating the abbreviation. So If you have 17 or 34 or whatever have 2 numbers ou 3 It only shows 3 or 1... Wo you have to manually rename all the islands abbreviation... what about to fix that incredibly wrong problem (for an add-on that helps you to generate blueprints it's pretty big)

  • Unfold again. If you already unfold a model and ask a new unfold, the island names become a pretty huge mess. You have multiple time the same name etc. It should just rip of all the names and do it again from scratch.

Anyone have these problems too?

Hey guys, I'm using quite a lot that add-on for few months. There are 2 bugs that are pretty annoying and time consuming: - Abreviation. I can't figure out if I do something wrong or if the script has a problem on that side. It only take the first number in count when automatically generating the abbreviation. So If you have 17 or 34 or whatever have 2 numbers ou 3 It only shows 3 or 1... Wo you have to manually rename all the islands abbreviation... what about to fix that incredibly wrong problem (for an add-on that helps you to generate blueprints it's pretty big) - Unfold again. If you already unfold a model and ask a new unfold, the island names become a pretty huge mess. You have multiple time the same name etc. It should just rip of all the names and do it again from scratch. Anyone have these problems too?
Member

Removed subscriber: @Blendify

Removed subscriber: @Blendify
Author
Member
  • Abbreviation: fixed in c960569 (upstream 1daeb8).
  • Unfold again: this behavior is on purpose, so that Unfold does not discard all your work on island naming. It never assigns a name twice (unless you already have this conflict in the original list).
- Abbreviation: fixed in c960569 (upstream 1daeb8). - Unfold again: this behavior is on purpose, so that Unfold does not discard all your work on island naming. It never assigns a name twice (unless you already have this conflict in the original list).

Hey Adam,

Thank you for fixing it. I'm a bit new to the developper side. Where can I get the updated script? At the top of the page?

About the Unfold again, I understand the point but in my case it always mess my work up. As soon as I had new Seams on the mesh (i.e. if islands are to big for the paper size I chose) and click Unfold another time, it gives me like 10 islands with the same number etc.
It never did the right job of renaming all the island without duplicates.
The only option, to not have duplicates, is to remove all seams and let it create it by itself, but it's not what I want as I know what I'm doing :)

Maybe I do something wrong.. I really don't know

Hey Adam, Thank you for fixing it. I'm a bit new to the developper side. Where can I get the updated script? At the top of the page? About the Unfold again, I understand the point but in my case it always mess my work up. As soon as I had new Seams on the mesh (i.e. if islands are to big for the paper size I chose) and click Unfold another time, it gives me like 10 islands with the same number etc. It never did the right job of renaming all the island without duplicates. The only option, to not have duplicates, is to remove all seams and let it create it by itself, but it's not what I want as I know what I'm doing :) Maybe I do something wrong.. I really don't know

This comment was removed by @MaxenceLeretdAubigny

*This comment was removed by @MaxenceLeretdAubigny*
Brendon Murphy was unassigned by Adam Dominec 2017-08-06 14:25:42 +02:00
Author
Member

Maxence,
this task (38441) is closed and the links at the top of this page don't work anymore. You can download the file from [blender addons ]] repository or from [ https:*raw.githubusercontent.com/addam/Export-Paper-Model-from-Blender/master/io_export_paper_model.py | github , currently these are both the same.

Can you please check that the naming is wrong, even with this version?
And if it is, what is exactly your workflow?
Do you use Auto Label, or do you set the island names by hand?

Maxence, this task (38441) is closed and the links at the top of this page don't work anymore. You can download the file from [blender addons ]] repository or from [[ https:*raw.githubusercontent.com/addam/Export-Paper-Model-from-Blender/master/io_export_paper_model.py | github ](https:*git.blender.org/gitweb/gitweb.cgi/blender-addons.git/blob_plain/HEAD:/io_export_paper_model.py), currently these are both the same. Can you please check that the naming is wrong, even with this version? And if it is, what is exactly your workflow? Do you use Auto Label, or do you set the island names by hand?
Adam Dominec self-assigned this 2017-08-06 14:58:41 +02:00
Author
Member

(I assume that discussion causes no harm here and I assign this outdated task to myself.)

(I assume that discussion causes no harm here and I assign this outdated task to myself.)

Added subscriber: @schneck007

Added subscriber: @schneck007

I found a bug. my modell will not unfold in Blender. I have to triangulate it to work. In the untrigualated version I got " Error please report"

In pepakura it works all untrigulated find.

I found a bug. my modell will not unfold in Blender. I have to triangulate it to work. In the untrigualated version I got " Error please report" In pepakura it works all untrigulated find.
Author
Member

Christin, this task is closed. If you want to make a helpful bug report, please send it either to my e-mail or to BlenderArtists, and attach the model.

However, it doesn't even seem there is a bug. Some models cannot be exported without triangulation. The script could triangulate for you, of course, but that could damage your data -- that's why you have to call the Triangulate operator yourself.

Christin, this task is closed. If you want to make a helpful bug report, please send it either to my e-mail or to BlenderArtists, and attach the model. However, it doesn't even seem there is a bug. Some models cannot be exported without triangulation. The script could triangulate for you, of course, but that could damage your data -- that's why you have to call the Triangulate operator yourself.
Sign in to join this conversation.
No Milestone
No project
No Assignees
9 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#38441
No description provided.